<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<jsp:include page = "../metadatos.jsp" flush = "True" />
<html>
    <head>
        <title>Terminal Punto de Venta -- Sistemas Tarry</title>
    </head>
    <script>
        function enter()
        {
            document.getElementById("cb").submit();
        }
    </script>
    <body>
        <div class="wrapper">
            <jsp:include page = "../headerERP.jsp" flush = "True" />
            <main class="content">
                <form class="formee" id="cb" method="post" action="./TarryTPV?action=entreArticulo"> 
                    <fieldset>
                        <legend>Entre articulo</legend>
                         <c:if test="${principalTPV.nErrores>0}">
                            <div class="formee-msg-error">
                                <h3>Incidencias:</h3>
                                <ul>
                                    <c:forEach items="${principalTPV.errores}" var="e">
                                        <li><c:out value="${e}"/></li>
                                        </c:forEach>
                                </ul>
                            </div> 
                        </c:if>
                        <div class="grid-12-12">
                            <label>CODIGO DE BARRAS<em class="formee-req" >*</em></label>
                            <input type="text" name="cb"  autofocus="yes"  onchange="enter()"/>
                        </div>
                    </fieldset>
                </form>
                <!-- INICIA LISTA DE ITEMS VENTA -->
                <form id="articulos" method="post" action="./TarryTPV?action=editaPiezasArticulo" class="formee">
                    <center>
                        <div align="center">                            
                            <div class="grid-2-12">
                                <input type="button"  value="cerrar venta"  onclick="popup('./TarryTPV?action=cerrarVentaPopUp&index=1', 400, 400);"/>
                            </div>
                            <div class="grid-2-12">
                                <input type="button" value="pausar venta"  onclick="location.href = '#'"/>
                            </div>
                            <div class="grid-2-12">
                                <input type="button" value="reanudar venta"  onclick="location.href = '#'"/>
                            </div>
                            <div class="grid-2-12">
                                <input type="button" value="cancelar venta"  onclick="location.href = './TarryTPV?action=start'"/>
                            </div>
                            <div class="grid-2-12">
                                <input type="button" value="realizar corte"  onclick="location.href = '#'"/>
                            </div>
                            <div class="grid-2-12">
                                <input type="button" value="configuraciones"  onclick="popup('./TarryTPV?action=loginConfigTPV&index=1', 400, 400);"/>
                            </div>
                        </div>
                        <table width="1000" border="0" class="bordered">
                            <thead>
                                <tr>
                            <th><div align="center">ID TICKET</div></th>
                            <th><div align="center">CB</div></th>
                            <th><div align="center">DESCRIPCION</div></th>
                            <th><div align="center">CANTIDAD</div></th>
                            <th><div align="center">P.P.</div></th>
                            <th><div align="center">SUB TOTAL</div></th>
                            <th><div align="center">CANCELAR</div></th>
                            </tr>
                            </thead>
                            <tbody>
                                <c:forEach items="${principalTPV.itemsVenta}" var="item">
                            <input type="hidden" value="<c:out value="${item.id}"/>" name="id_articulo_<c:out value="${item.id}"/>"/>
                                    <tr>
                                        <td><c:out value="${item.idTicket}"/></td>
                                        <td><c:out value="${item.idItem}"/></td>
                                        <td><c:out value="${item.descripcion}"/> </td>
                                        <td>
                                            <div class="grid-6-12">
                                                <select name="cantidad_item_<c:out value="${item.id}"/>" onchange="this.form.submit()">
                                                    <option value="1" <c:if test="${item.cantidad == 1}"> selected="selected"</c:if> > s1 PZA.</option>
                                                    <option value="2" <c:if test="${item.cantidad == 2}"> selected="selected"</c:if>>2 PZAS.</option>
                                                    <option value="3" <c:if test="${item.cantidad == 3}"> selected="selected"</c:if>>3 PZAS.</option>
                                                    <option value="4" <c:if test="${item.cantidad == 4}"> selected="selected"</c:if>>4 PZAS.</option>
                                                    <option value="5" <c:if test="${item.cantidad == 5}"> selected="selected"</c:if>>5 PZAS.</option>
                                                    <option value="6" <c:if test="${item.cantidad == 6}"> selected="selected"</c:if>>6 PZAS.</option>
                                                    <option value="7" <c:if test="${item.cantidad == 7}"> selected="selected"</c:if>>7 PZAS.</option>
                                                    <option value="8" <c:if test="${item.cantidad == 8}"> selected="selected"</c:if>>8 PZAS.</option>
                                                    <option value="9" <c:if test="${item.cantidad == 9}"> selected="selected"</c:if>>9 PZAS.</option>
                                                    <option value="10"<c:if test="${item.cantidad == 10}"> selected="selected"</c:if>>10 PZAS.</option>
                                                    <option value="11"<c:if test="${item.cantidad == 11}"> selected="selected"</c:if>>11 PZAS.</option>
                                                    <option value="12"<c:if test="${item.cantidad == 12}"> selected="selected"</c:if>>12 PZAS.</option>
                                                    </select>
                                                </div>
                                            </td>
                                            <td><c:out value="${item.precioPublico}"/></td>
                                        <td><c:out value="${item.subTotal}"/></td>
                                        <td ><img src="./resources/delete-icon.png" width="20" height="20" onclick="popup('./TarryTPV?action=cancelaItem&index=1&idItemVenta=<c:out value="${item.id}"/>', 300, 200);"/></td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                            <thead>
                                <tr>
                                    <th colspan="6"><div align="right">TOTAL</div></th>
                            <th><c:out value="${principalTPV.totalVenta}"/> </th>
                            </tr>
                            </thead>
                        </table>
                    </center>
                </form>
            </main>
        </div>
    </body>
</html>
